package com.bwie.doctor.service.impl;

import com.bwie.doctor.domain.po.MedDoctor;
import com.bwie.doctor.mapper.RegisteredMapper;
import com.bwie.doctor.service.RegisteredService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;

import java.math.BigDecimal;

@Service
public class RegisteredServiceImpl implements RegisteredService {
    @Autowired
    private RegisteredMapper registeredMapper;

    /**
     * 挂号
     * @return
     */
    @Override
    public void register(String dockerName, String patientName) {
        registeredMapper.register(dockerName,patientName);
    }

    /**
     * 取消挂号
     * @param dockerName
     * @param patientName
     * @return
     */
    @Transactional
    @Override
    public void cancelRegister(String dockerName, String patientName) {
        //根据医生名称查询医生挂号费用
        MedDoctor medDoctor = registeredMapper.getDoctorMoney(dockerName);
        //根据患者名称查询患者id
        Long patientId = registeredMapper.getPatientId(patientName);
        //更改挂号状态为已取消
        registeredMapper.cancelRegister(medDoctor.getDoctorId(),patientId,1);
        //根据医生挂号费用和患者id退还患者金额
//        registeredMapper.updUpPatientMoney(medDoctor.getDoctorPrice(),patientId);
    }

    /**
     * 查询挂号状态
     * @param dockerName
     * @param patientName
     * @return
     */
    @Override
    public Integer getRegisterState(String dockerName, String patientName) {
        return registeredMapper.getRegisterState(dockerName,patientName);
    }

    /**
     * 根据患者姓名查询挂号记录
     * @param
     * @param patientName
     * @return
     */
    @Override
    public Integer getRegisterByPatientName(String patientName) {
        return registeredMapper.getRegisterByPatientName(patientName);
    }


}
